<% include("../public/commonheader.html"){}%><!-- 配置文件 -->

<div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <div class="layui-form-item">
                        <label for="L_username" class="layui-form-label">
                            <span class="x-red">*</span>${L.username}</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_username" name="username" value="${info.username}" required="" lay-verify="username" autocomplete="off" class="layui-input"></div>
                        <div class="layui-form-mid layui-word-aux">
                            <span class="x-red">*</span>将会成为唯一的登录名</div></div>
                    <div class="layui-form-item">
                        <label for="L_email" class="layui-form-label">
                            <span class="x-red">*</span>${L.email}</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_email" name="email" value="${info.email}" required="" lay-verify="email" autocomplete="off" class="layui-input"></div>
                    </div>
					<div class="layui-form-item">
                        <label for="L_mobile" class="layui-form-label">
                            <span class="x-red">*</span>${L.mobile}</label>
                        <div class="layui-input-inline">
                            <input type="text" id="L_mobile" name="mobile" value="${info.mobile}" required="" lay-verify="phone" autocomplete="off" class="layui-input"></div>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_password" class="layui-form-label">
                            <span class="x-red"></span>${L.password}</label>
                        <div class="layui-input-inline">
                            <input type="password" id="L_password" name="password" required="" lay-verify="password" autocomplete="off" class="layui-input"></div>
                           <div class="layui-form-mid layui-word-aux">6到16个字符</div>
						</div>
                    <div class="layui-form-item">
                        <label for="L_role_id" class="layui-form-label">
                            <span class="x-red">*</span>${L.role}</label>
                        <div class="layui-input-inline">
                            <select name="role_id">
                              <option value="0">${L.plselect}</option>
                              <%for(role in roles){%>
                              <option value="${role.role_id}"<% if(info.role_id==role.role_id){%> selected="true"<%}%>>${role.caption!}</option>
                              <%}%>
                           </select>
                        </div>
                    </div>

					<div class="layui-form-item">
                        <label for="L_status" class="layui-form-label">
                            <span class="x-red">*</span>状态</label>
                        <div class="layui-input-block">
                            <input type="checkbox" id="L_status" name="status" lay-skin="switch" lay-filter="switchTest" value="1" lay-text="正常|禁用" <% if(info.status=='1'){%> checked='1'<%}%><% if(info.uid=='1'){%> disabled='disabled'<%}%>/>
						</div>
                    </div>

                    <div class="layui-form-item">
                        <label for="L_submit" class="layui-form-label"></label>
						<input type="hidden" name="uid" value="${info.uid}"/>
                        <button class="layui-btn" lay-filter="edit" lay-submit="">提交</button>
				    </div>
                </form>
            </div>
        </div>

<% include("../public/commonfooter.html"){}%>
<script>
layui.use(['form', 'layer','jquery'],
            function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;

                //自定义验证规则
                form.verify({
                    username: function(value) {
                        if (value.length < 3) {
                            return '用户名至少得3个字符';
                        }
                    },
                    password:function(value){if(value!="" && value.length<6){return '密码必须6到12位';}},
                    repass: function(value) {
                        if ($('#L_password').val() != $('#L_repass').val()) {
                            return '两次密码不一致';
                        }
                    }
                });

                //监听提交
                form.on('submit(edit)',
                function(data) {
					$.post(jkas.url("/admin/admins/edit"),data.field,function(result)
					{
                     if(200==result.code)
					 {
                    //发异步，把数据提交给php
                      layer.alert("修改成功", {
                        icon: 6
                      },
                      function() {
                        //关闭当前frame
                        Sca.close();

                        // 可以对父窗口进行刷新 
                        Sca.father_reload();
                      });
					  }
					  else
					  { layer.alert("操作失败 "+result.msg, {
                        icon: 5
                        });
					  }
				   },"json");
                    return false;
                });

            });
</script>
